function setOverload(target, fn) {
    //注意,target只是原函数的引用,修改这个引用不会直接修改原函数,所以return
    var oldTarget = target;
    target = function(){
        if (arguments.length === fn.length) {
            return fn.apply(this, arguments);
        } else {
            return oldTarget.apply(this, arguments);
        }
    };
    return target;
}


function method(){
    return "没找到对应重载";
}

method = setOverload(method, function(a){return a;});
method = setOverload(method, function(a,b){return a+b;});
method = setOverload(method, function(a,b,c){return a+b+c;});

console.log(method(1));
console.log(method(1,2));
console.log(method(1,2,3));
console.log(method(1,2,3,4));